package com.bll.tsdoa.controller;


import com.bll.tsdoa.dto.PatternDto;
import com.bll.tsdoa.entity.Result;
import com.bll.tsdoa.service.PatternService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 排样方案(pattern)表控制层
 *
 * @author makejava
 * @since 2025-02-20 00:04:36
 */
@RestController
@RequestMapping("/oneDimension/getPattern")
@Slf4j
public class PatternController {

    @Resource
    private PatternService patternService;

    /**
     * @return
     */
    @GetMapping()
    public Result getPattern() {
        if (patternService.isError())
            return Result.error("输入的零件超出原料范围");
        List<PatternDto> patternList = patternService.getPattern();
        if (patternList == null || patternList.isEmpty()) {
            return Result.error("无法找到排样方案");
        }
        return Result.success(patternList);
    }
}

